package asia.myjhotel.xiaozhiagent.tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.ToolMemoryId;
import org.springframework.stereotype.Component;

@Component
public class CalculatorTools {

    @Tool(name = "sum", value = "两数相加")
    double sum(@ToolMemoryId int memoryId,
               @P(value = "a", required = true) double a,
               @P(value = "b", required = true) double b) {
        System.out.println("调用加法运算 memoryId:" + memoryId + " a:" + a + " b:" + b);
        return a + b;
    }

    @Tool(name = "squareRoot", value = "数平方根")
    double squareRoot(@ToolMemoryId int memoryId,
                      @P(value = "x", required = true) double x) {
        System.out.println("调用平方根运算 memoryId:" + memoryId + " x:" + x);
        return Math.sqrt(x);
    }
}